﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using PowerCreator.LMS.Common.Script;
//using PowerCreator.LMS.Logic.Common;

public partial class sysadmin_CourseManager_CheckUpResourceList : System.Web.UI.Page
{
    //PowerCreator.LMS.Logic.CourseManager.ManagerCourseResourceType courseResourceTypeManager = new PowerCreator.LMS.Logic.CourseManager.ManagerCourseResourceType();
    //PowerCreator.LMS.Logic.CourseManager.ManagerResourceInfo resourceManage = new PowerCreator.LMS.Logic.CourseManager.ManagerResourceInfo();

    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
        //    string search = GetSearch();
        //    BinderPager(search);
        //    BinderGV(search,1);
        //}
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderPager(search);
        BinderGV(search, 1);
    }

    private string GetSearch()
    {
        StringBuilder sbSearch = new StringBuilder();
        //sbSearch.Append(" CourseID=0 and ");
        //if (string.IsNullOrEmpty(txtResourceName.Text))
        //{
        //    sbSearch.Append(string.Format(" ResourceName like '%{0}%' and ", txtResourceName.Text));
        //}     
        //sbSearch.Append(" 1=1 ");
        return sbSearch.ToString();
    }
    private void BinderGV(string search, int pageIndex)
    {
        //DataTable dt = new DataTable();
        //dt = resourceManage.Query(search, FBasePage.PageSize(), pageIndex);
        //dt.Columns.Add("NewTypeName");
        //DataTable dttype = new DataTable();
        //dttype = courseResourceTypeManager.Query("");
        //for (int i = 0; i < dt.Rows.Count; i++)
        //{
        //    for (int j = 0; j < dttype.Rows.Count; j++)
        //    {
        //        if (dttype.Rows[j]["TypeID"].ToString() == dt.Rows[i]["ResourceTypeID"].ToString())
        //        {
        //            dt.Rows[i]["NewTypeName"] = dttype.Rows[j]["TypeName"].ToString();
        //        }
        //    }
        //}
        //rtpResourceList.DataSource = dt;
        //rtpResourceList.DataBind();
    }
    private void BinderPager(string search)
    {
        //AspNetPager1.RecordCount = resourceManage.Count(search);
        //AspNetPager1.PageSize = FBasePage.PageSize();
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderGV(search, AspNetPager1.CurrentPageIndex);
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        string url = "ResourceList.aspx";
        Script.RedirectURL(url);
    }
    protected void rtpResourceList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (string.Compare(e.CommandName.ToString(), "mydel") == 0)
        {
            //if (resourceManage.Delete(int.Parse(e.CommandArgument.ToString())))
            //{
            //    string search = GetSearch();
            //    BinderPager(search);
            //    BinderGV(search, AspNetPager1.CurrentPageIndex);
            //}
        }
    }
}
